<template>
	<view :style="themeColor">
		<view class="page">
			<view class="flex benben-position-layout flex flex-wrap align-center homePage_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
				<view class='flex flex-wrap justify-between align-center homePage_fd0_0'>
					<view class="index_1" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/shouye/oneAppointment/companyProfile`">知行游泳健身</view>
					<view class='homePage_fd0_0_c0'>首页</view>
					<view class="index_1"></view>
				</view>
			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>

			<view class="loading_css" v-if="isShow">
				<u-loading size="36" color="#F35D2A"></u-loading>
				<view>加载中</view>
			</view>

			<block v-else>
				<view class='flex flex-wrap align-center homePage_fd1_0_c1'>
					<view class='flex flex-wrap align-center homePage_fd1_0_c1_c0' @tap.stop="handleJumpDiy"
						data-type="navigateTo" :data-url="`/pages/sousuo/searchye/searchye`">
						<image class='homePage_fd1_0_c1_c0_c0' mode="aspectFit" :src='STATIC_URL+"482.png"'>
						</image>
						<input style="flex: 1;" type="text" :placeholder="`搜索`" confirm-type="done" :maxlength="-1" :disabled='true' placeholder-style="color:#999;font-size:28rpx" />
					</view>
					<view class='flex flex-wrap align-center homePage_fd1_0_c1_c1'>
						<!-- <image class='homePage_fd1_0_c1_c1_c0' mode="aspectFit" :src='STATIC_URL+"483.png"'
							@tap.stop="handleJumpDiy" data-type="navigateTo"
							:data-url="`/pages/sousuo/punchinTasks/punchinTasks`"></image> -->
						<view class='flex flex-wrap align-center homePage_fd1_0_c1_c1_c1' @tap.stop="handleJumpDiy"
							data-type="navigateTo" :data-url="`/pages/grzx/myNews/myNews`">
							<image class='homePage_fd1_0_c1_c1_c0' mode="aspectFit" :src='STATIC_URL+"484.png"'>
							</image>
							<benben-message-num class='homePage_fd1_0_c1_c1_c1_c1' size='24' color='#fff'
								:messageNum="total_nums" background-color='#D5252A'>
							</benben-message-num>
						</view>
					</view>
				</view>
				<!---flex布局flex布局开始-->
				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout homePage_flex_1">
					<view class='flex flex-direction flex-wrap align-stretch'>

						<view class='flex flex-wrap align-center homePage_fd1_0_c2'>
							<view style="position: relative">
								<swiper ref="benbenSwiperfd1_0_c2_c0"
									@change="bannerIndexfd1_0_c2_c0 = $event.detail.current"
									class='flex position-relative homePage_fd1_0_c2_c0' previous-margin="0rpx"
									next-margin="0rpx" :display-multiple-items="1" :interval="5000" :duration="500"
									:autoplay='true' :circular='true'>
									<swiper-item @click="swiperClick(k)" class='flex  homePage_fd1_0_c2_c0'
										v-for="(v, k) in swiperList" :key="k">
										<image class='homePage_fd1_0_c2_c0_c1_c0' mode="aspectFill" :src='v.thumb'>
										</image>
									</swiper-item>
								</swiper>
								<view style="position: absolute"
									class="flex dot flex align-center justify-center homePage_swiperDotfd1_0_c2_c0">
									<template v-for="(item, index) in (swiperList.length)">
										<view :key="index" v-if="bannerIndexfd1_0_c2_c0 == index"
											class="flex dot selected flex align-center justify-center homePage_swiperDotSelectedfd1_0_c2_c0">
										</view>
										<view :key="index" v-else
											class="flex dot unselected flex align-center justify-center homePage_swiperDotUnselectedfd1_0_c2_c0">
										</view>
									</template>
								</view>
							</view>
						</view>
						<view class="classification">
							<view class="classification_item" v-for="(item, index) in classification" :key="index" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/shouye/oneAppointment/classCourses?cate_id=${item.aid}`">
								<image :src='item.thumb' mode=""></image>
								<view class="">{{item.name}}</view>
							</view>
							<view class="classification_item" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/shouye/oneAppointment/classCourses`">
								<image :src='STATIC_URL+"432.png"' mode=""></image>
								<view class="">更多</view>
							</view>
						</view>
						<view class="vip" @tap.stop="handleJumpDiy" data-type="navigateTo" :data-url="`/pages/xitongs/member/member`">

						</view>
					</view>
				</view>

				<view class="course_list">
					<view class="course_title" @tap.stop="handleJumpDiy"
						data-type="navigateTo" :data-url="`/pages/shouye/oneAppointment/oneAppointment`">
						<view class="course_title_le">一键预约</view>
						<view class="course_title_ri">
							<text>更多</text>
							<u-icon size="24" color="#999" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="course_tabs">
						<view class="tabs_item" v-for="(item, index) in weekType" :key="index" @tap.stop="selectType1(item.id)">
							<text :class="course_type_one == item.id ? 'active_tabs_item' : ''">{{item.name}}</text>
							<text :class="course_type_one == item.id ? 'active_week_icon' : ''"></text>
						</view>
						
					</view>
					<template v-for="(item, index) in list1">
						<reservation :item="item" :key="index"></reservation>
					</template>
					<view class="noData_other" v-if="list1.length == 0 && !isShow">
						<image :src='STATIC_URL+"no.png"'></image>
					</view>
					
				</view>
				
				<view class="course_list">
					<view class="course_title" @tap.stop="handleJumpDiy"
						data-type="navigateTo" :data-url="`/pages/shouye/oneAppointment/recommendCourses`">
						<view class="course_title_le">推荐课程</view>
						<view class="course_title_ri">
							<text>更多</text>
							<u-icon size="24" color="#999" name="arrow-right"></u-icon>
						</view>
					</view>
					<view class="course_tabs">
						<view class="tabs_item" v-for="(item, index) in courseType" :key="index" @tap.stop="selectType2(item.id)">
							<text :class="course_type_Two == item.id ? 'active_tabs_item' : ''">{{item.name}}</text>
							<text :class="course_type_Two == item.id ? 'active_icon' : ''"></text>
						</view>
						
					</view>
					<template v-for="(item,index) in list2">
						<recommend :item="item" :index="index"></recommend>
					</template>
					<view class="noData_other" v-if="list2.length == 0 && !isShow">
						<image :src='STATIC_URL+"no.png"'></image>
					</view>
				</view>
				<view class="course_list">
					<view class="course_title" @tap.stop="handleJumpDiy"
						data-type="navigateTo" :data-url="`/pages/shouye/oneAppointment/recommendCoach`">
						<view class="course_title_le">推荐教练</view>
						<view class="course_title_ri">
							<text>更多</text>
							<u-icon size="24" color="#999" name="arrow-right"></u-icon>
						</view>
					</view>
					<template v-for="(item,index) in list3">
						<coach :item="item" :key="index" :baColor="'#f5f5f5'"></coach>
					</template>
					<view class="noData_other" v-if="list3.length == 0 && !isShow">
						<image :src='STATIC_URL+"no.png"'></image>
					</view>
				</view>
			</block>
		</view>
	</view>
</template>
<script>
	import reservation from "@/components/reservation/reservation.vue"
	import recommend from "@/components/reservation/recommend.vue"
	import coach from "@/components/reservation/coach.vue"
	export default {
		components: {
			reservation,
			recommend,
			coach
		},


		data() {
			return {
				"popupShow1698283017948": false,
				"bannerIndexfd1_0_c2_c0": 0,
				"home_title": global.home_title,
				"home_desc": global.home_desc,
				"swiperList": [],
				"giantImg": {}, // 知行合一图片
				"isShow": true,
				"list": [],
				"page": 1,
				"is_pull": true,
				"last_page": 1,
				"status": 'loadmore',
				"iconType": 'flower',
				"loadText": {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '我也是有底线的'
				},

				"total_nums": 0,
				"userInfo": {},
				couponList: [],
				receiveCouponLoading: false,
				courseType: [
					{
						id: 1,
						name: '单节课'
					},
					{
						id: 2,
						name: '团体课'
					},
					{
						id: 3,
						name: '私教课'
					}
				],
				weekType: [
					{
						id: 0,
						name: '周日'
					},
					{
						id: 1,
						name: '周一'
					},
					{
						id: 2,
						name: '周二'
					},
					{
						id: 3,
						name: '周三'
					},
					{
						id: 4,
						name: '周四'
					},
					{
						id: 5,
						name: '周五'
					},
					{
						id: 6,
						name: '周六'
					}
				],
				course_type_one: 0,
				course_type_Two: 1,
				list1: [],  // 预约课程
				list2: [],  // 推荐课程
				list3: [],  // 教练列表
				classification: [],  // 课程分类id
				invite_code: "",  // 分享的邀请码
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
		},
		watch: {},
		onLoad(options) {
			let {invite_code} = options;
			if (invite_code !== undefined) this.invite_code = invite_code;
			if (this.invite_code) {
				uni.setStorageSync('invite_code', this.invite_code);
			}
			this.getSwiper();
			this.getReservation();
			this.getRecommend();
			this.getCoach();
			this.getCourseClassification();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {
			if (global.token) {
				this.getNewsNum();
			}
			this.page = 1;
			this.is_pull = true;
		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			this.getSwiper();
			this.getReservation();
			this.getRecommend();
			this.getCoach();
			this.getCourseClassification();
		},
		// 上拉加载
		onReachBottom() {
			
		},
		onPageScroll(e) {

		},
		methods: {
			// 课程分类  post6556232bd672a
			getCourseClassification() {
				this.$api.post(global.apiUrls.post6556232bd672a, {
					from: 'home'
				}).then(res =>{
					if (res.data.code == 1) {
						this.classification = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			
			
			selectType1(id) {
				this.course_type_one = id;
				this.getReservation();
			},
			selectType2(id) {
				this.course_type_Two = id;
				this.getRecommend();
			},
			// 预约课程  post65b74570e291f
			getReservation() {
				this.$api.post(global.apiUrls.post65b74570e291f, {
					week: this.course_type_one
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.list1 = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 推荐课程  post65b7474ebccfa
			getRecommend() {
				this.$api.post(global.apiUrls.post65b7474ebccfa, {
					course_type: this.course_type_Two
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.list2 = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 教练列表  post65b1feb0493af
			getCoach() {
				this.$api.post(global.apiUrls.post65b1feb0493af, {
					from: 'home'
				}).then(res => {
					// console.log(res);
					if (res.data.code == 1) {
						this.list3 = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 获取消息未读数  6553174f6dafa
			getNewsNum() {
				this.$api.post(global.API_VERSION + '6553174f6dafa', {

				}).then(res => {
					if (res.data.code == 1) {
						this.total_nums = res.data.data.total_nums;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},

			imageClick(index) {
				// data_type 1 文章  2视频
				if (this.list[index].data_type == 1) {
					uni.navigateTo({
						url: '/pages/guanzhu/maTtention/maTtention?id=' + this.list[index].aid
					})
				}

			},
			wapperClick(item) {
				if (item.data_type == 1) {
					uni.navigateTo({
						url: '/pages/guanzhu/maTtention/maTtention?id=' + item.aid
					})
				}

			},


			// 轮播图  63a5821ddfe77
			getSwiper() {
				this.$api.post(global.API_VERSION + '63a5821ddfe77', {
					operationadstype_id: 1
				}).then(res => {
					uni.stopPullDownRefresh();
					if (res.data.code == 1) {
						this.swiperList = res.data.data;
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			swiperClick(index) {
				if (global.token) {
					if (this.swiperList[index].link_type == 1) {
						// 商品
						if (this.swiperList[index].data_type == 1) {

						} else {
							uni.navigateTo({
								url: '/pages/grzx/merchanDisedetails/merchanDisedetails?id=' + this.swiperList[
									index].href
							})
						}
					}
				} else {
					uni.navigateTo({
						url: '/pages/tabBar/passwordLogin/passwordLogin'
					})
				}

			},

		}
	};
</script>
<style lang="scss" scoped>
	.course_list {
		background: #FFFFFF;
		padding: 32rpx;
		margin-top: 20rpx;

		.course_title {
			display: flex;
			justify-content: space-between;
			align-items: center;

			.course_title_le {
				font-size: 32rpx;
				font-weight: 500;
			}

			.course_title_ri {
				display: flex;
				align-items: center;
				font-size: 24rpx;
				color: #999;

				text {
					margin-right: 8rpx;
				}
			}
		}

		.course_tabs {
			display: flex;
			justify-content: space-between;
			padding: 32rpx 0 8rpx 0;

			.tabs_item {
				font-size: 28rpx;
				color: #666666;
				position: relative;
				z-index: 10;

				.active_icon {
					display: inline-block;
					background: #FF8157;
					width: 80rpx;
					height: 5rpx;
					border-radius: 3rpx;
					position: absolute;
					left: 50%;
					bottom: 6rpx;
					transform: translateX(-50%);
					z-index: 5;
				}
				.active_week_icon {
					display: inline-block;
					background: #FF8157;
					width: 50rpx;
					height: 5rpx;
					border-radius: 3rpx;
					position: absolute;
					left: 50%;
					bottom: 6rpx;
					transform: translateX(-50%);
					z-index: 5;
				}

				.active_tabs_item {
					color: #333 !important;
					font-size: 28rpx;
					font-weight: 500;
				}
			}
		}
	}

	.classification {
		display: flex;
		margin-top: 32rpx;

		.classification_item {
			width: 20%;
			text-align: center;
			font-size: 26rpx;

			image {
				width: 88rpx;
				height: 88rpx;
				margin-bottom: 16rpx;
			}
		}
	}

	.vip {
		margin: 0 24rpx;
		width: 702rpx;
		height: 120rpx;
		position: absolute;
		left: 0;
		bottom: 0;
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/254.png) no-repeat;
		background-size: 100% 100%;
	}

	.index_1 {
		width: 210rpx;
		font-size: 32rpx;
		font-weight: 600;
		color: #fff;
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/490.png) no-repeat;
		background-size: 100% auto;
		background-color: #f8f8f8;
	}

	.homePage_flex_0 {
		background: url(https://yongzhixing.niurenjianzhan.com/uploads/mini/490.png) no-repeat;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 99;
		top: 0rpx;
		background-size: 100% auto;
	}

	.homePage_fd0_0_c0 {
		color: #FFFFFF;
		font-size: 36rpx;
		font-weight: 400;
	}

	.homePage_fd0_0 {
		padding: 0rpx 32rpx;
		width: 100%;
	}

	.homePage_flex_1 {
		padding: 32rpx 32rpx 160rpx 32rpx;
		background: #fff;
		border-radius: 40rpx 40rpx 0 0;
		position: relative;
	}

	.homePage_fd1_0_c4_c1_c0_c1_c1_c3 {
		color: #666666;
		font-size: 24rpx;
		font-weight: 400;
		max-width: 45rpx;
		-webkit-line-clamp: 1;
		overflow: hidden;
		text-overflow: ellipsis;
		display: -webkit-box;
		-webkit-box-orient: vertical;
	}

	.homePage_fd1_0_c4_c1_c0_c1_c1_c2 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 13rpx 0rpx auto;
	}

	.homePage_fd1_0_c4_c1_c0_c1_c1_c1 {
		color: #666666;
		font-size: 24rpx;
		font-weight: 400;
		margin: 0rpx 0rpx 0rpx 12rpx;
	}

	.homePage_fd1_0_c4_c1_c0_c1_c1_c0 {
		width: 40rpx;
		height: 40rpx;
		border-radius: 20rpx;
	}

	.homePage_fd1_0_c4_c1_c0_c1_c0 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 500;
		padding: 24rpx 0rpx 24rpx 0rpx;
	}

	.homePage_fd1_0_c4_c1_c0_c1 {
		padding: 0rpx 25rpx 20rpx 20rpx;
	}

	.homePage_fd1_0_c4_c1_c0_c0 {
		width: 340rpx;
		height: 450rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.homePage_fd1_0_c4_c1_c0 {
		// padding: 0rpx 0rpx 24rpx 0rpx;
	}

	.homePage_fd1_0_c4_c0_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
	}

	.homePage_fd1_0_c3_c0 {
		width: 220rpx;
		height: 208rpx;
		margin: 0rpx 0rpx 0rpx 0rpx;
		border-radius: 16rpx;
	}

	.homePage_fd1_0_c3 {
		padding: 24rpx 0rpx 20rpx 0rpx;
	}

	.homePage_numberfd1_0_c2_c0_c0 {
		background: #525050;
		position: absolute;
		bottom: 20rpx;
		right: 30rpx;
		width: 80rpx;
		height: 40rpx;
		border-radius: 6rpx 6rpx 6rpx 6rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		line-height: 46rpx;
		font-weight: 400;
	}

	.homePage_fd1_0_c2_c0_c1_c0 {
		width: 686rpx;
		height: 340rpx;
		border-radius: 24rpx;
	}

	.homePage_fd1_0_c2_c0 {
		width: 686rpx;
		height: 340rpx;
		border-radius: 24rpx;
	}

	.homePage_swiperDotUnselectedfd1_0_c2_c0 {
		background: #333;
		width: 8rpx;
		height: 8rpx;
		border-radius: 4rpx;
		margin: 0rpx 6rpx 0rpx 0rpx;
		font-size: 24rpx;
	}

	.homePage_swiperDotSelectedfd1_0_c2_c0 {
		background: #333;
		width: 32rpx;
		height: 8rpx;
		border-radius: 4rpx;
		margin: 0rpx 6rpx 0rpx 0rpx;
		font-size: 24rpx;
	}

	::v-deep .homePage_swiperDotfd1_0_c2_c0 {
		position: absolute;
		bottom: 20rpx;
		left: 0rpx;
		right: 0rpx;
	}

	.homePage_fd1_0_c2 {
		width: 690rpx;
	}

	.homePage_fd1_0_c1_c1_c1_c1 {
		position: absolute;
		top: -15rpx;
		right: -10rpx;
	}

	.homePage_fd1_0_c1_c1_c1 {
		position: relative;
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.homePage_fd1_0_c1_c1_c0 {
		width: 40rpx;
		height: 38rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.homePage_fd1_0_c1_c1 {
		margin: 0rpx 0rpx 0rpx auto;
	}

	.homePage_fd1_0_c1_c0_c0 {
		width: 32rpx;
		height: 32rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 16rpx 0rpx 24rpx;
	}

	.homePage_fd1_0_c1_c0 {
		background: #FFFFFF;
		border-radius: 36rpx 36rpx 36rpx 36rpx;
		width: 614rpx;
		height: 72rpx;
	}

	.homePage_fd1_0_c1 {
		padding: 32rpx;
	}

	.homePage_fd1_0_c0 {
		color: #FFFFFF;
		font-size: 36rpx;
		font-weight: 400;
	}

	.homePage_fd2_0_c4 {
		background: linear-gradient(165deg, #BB4833 0%, #962F1D 100%);
		border-radius: 34rpx 34rpx 34rpx 34rpx;
		width: 396rpx;
		line-height: 54rpx;
		font-size: 34rpx;
		color: #fff;
		height: 54rpx;
		box-shadow: 5rpx 4rpx 4rpx 1rpx rgba(161, 55, 35, 0.16);
		margin: 17rpx 0rpx 0rpx 0rpx;
	}

	.homePage_fd2_0_c3 {
		width: 50rpx;
		height: 50rpx;
		position: absolute;
		right: 0rpx;
		top: 7rpx;
	}

	.homePage_fd2_0_c2_c0 {
		color: #999999;
		font-size: 17rpx;
		font-weight: 400;
		width: 254rpx;
		text-align: center;
	}

	.homePage_fd2_0_c1 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/700.png) no-repeat;
		height: 126rpx;
		width: 401rpx;
		background-size: 100% auto;
		padding: 0rpx 0rpx 0rpx 0rpx;
		margin: 24rpx 0rpx 15rpx 0rpx;
	}

	.homePage_fd2_0_c0_c1_c2 {
		color: rgba(51, 51, 51, 1);
		font-size: 20rpx;
	}

	.homePage_fd2_0_c0_c1_c1_c0 {
		color: #999999;
		font-size: 16rpx;
		font-weight: 400;
	}

	.homePage_fd2_0_c0_c1_c1 {
		margin: 17rpx 0rpx 5rpx 0rpx;
		color: rgba(51, 51, 51, 1);
		font-size: 20rpx;
	}

	.homePage_fd2_0_c0_c1_c0_c0 {
		color: #333333;
		font-size: 23rpx;
		font-weight: 400;
	}

	.homePage_fd2_0_c0_c1 {
		width: 200rpx;
		margin-left: 34rpx;
	}

	.homePage_fd2_0_c0_c0_c1_c0 {
		color: #FCF8F2;
		font-size: 19rpx;
		font-weight: 400;
	}

	.homePage_fd2_0_c0_c0_c1 {
		color: #FCF8F2;
		font-size: 32rpx;
		font-weight: 400;
		line-height: 28rpx;
	}

	.homePage_fd2_0_c0_c0_c0_c1 {
		color: #FCF8F2;
		font-size: 56rpx;
		font-weight: 400;
	}

	.homePage_fd2_0_c0_c0_c0_c0 {
		color: #FCF8F2;
		font-size: 17rpx;
		font-weight: 400;
	}

	.homePage_fd2_0_c0_c0 {
		width: 140rpx;
		padding: 0 24rpx 0 20rpx;
		text-align: center;
		box-sizing: border-box;
	}

	.homePage_fd2_0_c0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/700.png) no-repeat;
		height: 126rpx;
		width: 401rpx;
		background-size: 100% auto;
		padding: 0rpx 0rpx 0rpx 0rpx;
	}

	.homePage_fd2_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/699.png) no-repeat;
		width: 646rpx;
		height: 513rpx;
		background-size: 100% auto;
		padding: 52rpx 62rpx 45rpx 183rpx;
	}
</style>